;
var account_set_ops={
    init:function(){
        this.eventBind();
    },
    eventBind:function(){
        $(".wrap_account_set .save").click(function(){
            //防止重复点击
           var btn_target=$(this);
           if(btn_target.hasClass("disabled")){
               alert("正在提交后台处理,请不要重复提交~~");
               return;
           }

           //获取各个表单元素
            var nickname_target=$(".wrap_account_set input[name=nickname]");
            var nickname=nickname_target.val();

            var mobile_target=$(".wrap_account_set input[name=mobile]");
            var mobile=mobile_target.val();

            var email_target=$(".wrap_account_set input[name=email]");
            var email=email_target.val();

            var login_name_target=$(".wrap_account_set input[name=login_name]");
            var login_name=login_name_target.val();

            var login_pwd_target=$(".wrap_account_set input[name=login_pwd]");
            var login_pwd=login_pwd_target.val();

           if(nickname.length<1){
                common_ops.tip("用户名称不能为空~~",nickname_target);
                return;
            }

            if(mobile.length<1){
                common_ops.tip("手机号不能为空~~",mobile_target);
                return;
            }

            if(email.length<1){
                common_ops.tip("email不能为空~~",email_target);
                return;
            }

            if(login_name.length<1){
                common_ops.tip("登录名不能为空~~",login_name_target);
                return;
            }

            if(login_pwd.length<1){
                common_ops.tip("登录密码不能为空~~",login_pwd_target);
                return;
            }

            btn_target.addClass("disabled");

            var data={
                  nickname:nickname,
                  mobile:mobile,
                  email:email,
                  login_name:login_name,
                  login_pwd:login_pwd,
                  id:$(".wrap_account_set input[name=id]").val()

            };
            $.ajax({
                url:common_ops.buildWebUrl("/account/set"),
                type:'POST',
                data:data,
                dataType:'json',
                success:function(res){
                    btn_target.removeClass("disabled");

                    var callback=null;
                    if(res.code==200){
                        callback=function(){
                            window.location.href=common_ops.buildWebUrl("/account/index");
                        }
                    }

                    common_ops.alert(res.msg,callback);
                }
            });
        });
    }
};

$(window).ready(function(){
   account_set_ops.init();
});